package com.example.design.absFactory;

import com.example.design.absFactory.fruit.WenShiApple;
import com.example.design.absFactory.fruit.WenShiBanana;
import com.example.design.factory.FruitType;
import com.example.design.factory.interfactory.service.FruitFactory;
import com.example.design.factory.service.Fruit;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author: duk
 * @Date: 2021/12/8 16:33
 * @Description: 管理温室工厂
 */
@Component
public class WenShiFruitFactory implements FruitFactory {
    @Resource
    private WenShiBanana wenShiBanana;
    @Resource
    private WenShiApple wenShiApple;
    @Override
    public Fruit getFruit(FruitType fruitType) {
        Fruit fruit = null;
        switch (fruitType){
            case BANANA:
                fruit = wenShiBanana;
                break;
            case APPLE:
                fruit = wenShiApple;
                break;
            default:
                break;
        }
        return fruit;
    }
}
